package com.ftg.product.vfruit.controller;

import com.ftg.product.vfruit.pojo.Yinpin;
import com.ftg.product.vfruit.service.YinpinService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author zwl
 * Create on 2019/7/6 10:01
 * function
 */
@RestController
@CrossOrigin
@RequestMapping("/yinpin")
public class YinpinController {
    @Autowired
    YinpinService yinpinservice;
    @PostMapping("/show")
    public Map<String,Object> show(@RequestBody Yinpin pageH){
        PageHelper.startPage(pageH.getPage(),pageH.getLimit());
        List<Yinpin> list=yinpinservice.show(pageH);
        //包装查询后的结果
        PageInfo<Yinpin> page = new PageInfo<>(list);
        //实例化map结果集
        Map<String,Object> map = new HashMap<>();
        //将list中的数据放入map中
        map.put("data",list);
        //code码 为0
        map.put("code","0");
        //成功信息为success
        map.put("msg","success");
        //将总数据条数放入map中
        map.put("count",page.getTotal());
        //返回map
        return map;
    }
}
